using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class NoSite : BasePage
{
    public override Acms.Bll.Role.Roles[] AllowedRoles
    {
        get { return new Acms.Bll.Role.Roles[] { Acms.Bll.Role.Roles.Developer }; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (AcmsSite != null)
            {
                Response.Redirect("~/");
            }
        }
    }

    protected void dsSite_UpdatingData(object sender, Acms.DataControls.UpdatingDataEventArgs<Acms.Bll.Site> e)
    {
    }

    protected void dvSite_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
    {
        if (e.Exception == null)
        {
           int id = (int)e.Values[Acms.DataControls.SiteDataSource.Fields.Id.ToString()];
           AcmsConfigManager.SetAppSetting("SiteId", id.ToString());
           Response.Redirect("~/");
       }
    }

    private List<Acms.Bll.Site> sites;
    protected List<Acms.Bll.Site> Sites
    {
        get 
        {
            if (sites == null)
            {
                sites = Acms.Bll.Site.GetAll();
            }
            return sites;
        }
    }
    protected void dsSite_SelectData(object sender, Acms.DataControls.SelectEventArgs<Acms.Bll.Site> e)
    {
        e.SetData(Sites);
    }

    protected void gvSites_SelectedIndexChanged(object sender, EventArgs e)
    {
        Acms.Bll.Site site = Sites[gvSites.SelectedIndex];
        AcmsConfigManager.SetAppSetting("SiteId", site.Id.ToString());
        Response.Redirect("~/");
    }
}
